<?php

require_once ('lib/models/BaseModel.class.php');

class LevelModel extends BaseModel {
	public function __construct() {
		parent::__construct ();
	}
	
	/**
	 * getIdByName
	 * 根据等级名称获得等级ID
	 *
	 * @param string $name        	
	 */
	public function getIdByName($name) {
		if (is_null ( $this->_conn ) || empty ( $name )) {
			return false;
		}
		
		$query = "SELECT id FROM Levels WHERE name=:name LIMIT 1";
		$param = array (
				"name" => $name 
		);
		$map [] = array (
				"name",
				"string" 
		);
		$table = $this->_conn->select ( $query, $param, $map );
		if (count ( $table )) {
			return $table [0] ["id"];
		}
		return false;
	}
}

